const md = require('../../utils/md5.js');
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    var that = this;
    if (options.id != '') {
      that.setData({
        frid: options.id,
        memo: options.memo,
        memoname: options.memoname,
        status: options.status,
        name: options.name
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  formSubmit: function (e) {
    var that = this;
    console.log('form发生了submit事件，携带数据为：', e.detail.value);
    var formdata = e.detail.value;
    // if (formdata.memo.length == 0) {
    //   wx.showModal({
    //     title: '',
    //     content: '请输入备注名',
    //   })
    // }
    // 获取时间戳
    var apinameIsMeb = "/BO/BA_Friends/Modify";
    var timestamp = new Date().getTime();
    timestamp = parseInt(timestamp / 1000);
    var md5IsMeb = md.hexMD5(app.server.appid + timestamp + apinameIsMeb + app.server.appkey);
    var data = {};
    data.RelID = that.data.frid;
    data.Memo = formdata.decribe;
    data = JSON.stringify(data);
    wx.request({
      //后台接口地址
      url: app.server.url + apinameIsMeb,
      data: {
        sign: md5IsMeb,
        appid: app.server.appid,
        tmsp: timestamp,
        data: data
      },
      method: 'POST',
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        console.log(res);
        if (res.data.code == 0) {
          wx.navigateBack({
            delta:1
          })
        }
      }
    })
  },
})